//
//  DFDemoMenuListController.m
//  DFKit
//
//  Created by rujia chen on 17/6/13.
//  Copyright © 2017年 chenrj90. All rights reserved.
//

#import "DFDemoMenuListController.h"

@interface DFMenuItem : NSObject

@property (nonatomic, copy) NSString *title;

@end

NS_INLINE DFMenuItem *DFMakeMenuItem(NSString *title) {
    DFMenuItem *item = [[DFMenuItem alloc] init];
    item.title = title;
    return item;
}

@implementation DFMenuItem

@end


static NSString *kIdentifier = @"kIdentifier";
@interface DFDemoMenuListController ()

@property (nonatomic, strong) NSArray <DFMenuItem *> *menuItems;

@end

@implementation DFDemoMenuListController

+ (void)load {
    [DFRouter registerURL:DF_DEMO_MENU forViewController:[self class]];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kIdentifier];
    self.menuItems = @[
                       DFMakeMenuItem(@"UI"),
                       DFMakeMenuItem(@"分享")
                       ];
}

- (NSString *)title {
    return @"例子";
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.menuItems.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kIdentifier];
    DFMenuItem *item = self.menuItems[indexPath.row];
    cell.textLabel.text = item.title;
    return cell;
}


#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//    [self.navigationController pushViewController:[UIViewController new] animated:YES];
    [DFRouter openURL:DF_DEMO_SHARE];
}

@end
